
#ifndef TWEEN_H
#define TWEEN_H

// INCLUDES ********************************************************************

#include "Datatypes.h"

#include "Vector2D.h"

#include <map>

// FORWARD DECLARATIONS ********************************************************



/*******************************************************************************
 
 TODO:  - restklassen implementieren
        - tatsächliche fps benutzen für umrechnung duration
        - std::map mit string als animation type statt enums?
 
*******************************************************************************/

// *****************************************************************************

//! Tween
//! 
//! Most basic tweening class, there is no easing involved, everything is
//! a linear motion

// *****************************************************************************

namespace Meteor 
{
    class Tween
    {
        public:
            typedef enum
            {
                Alpha,
                Scale,
                Rotation,
                Position,
                NumAttributes
                
            } TweenAttribute;
        
            typedef enum
            {
                EaseNone,
                EaseIn,
                EaseOut,
                EaseInOut,
                NumEaseTypes
            } EaseType;
    
            Tween( const TweenAttribute attr, const EaseType type,
                   const float startValue, const float targetValue,
                   const float duration);
        
            Tween( const TweenAttribute attr, const EaseType type,
                   const Vector2D& startValue,
                   const Vector2D& targetValue,
                   const float duration);
        
            Tween( const Tween& old);
        
            virtual ~Tween(){};

            const float TargetValue() const;
        
            const float Change() const;
        
            const TweenAttribute Attribute() const;
        
            const bool Finished() const;
        
            virtual const Vector2D Update( const float time);
    
        protected:
            TweenAttribute mAttribute;
        
            EaseType mEaseType;
        
            Vector2D mStartValue;
        
            Vector2D mTargetValue;
        
            Vector2D mChange;
        
            float mDuration;
        
            bool mFinished;

            void IsFinished( const float value);
        
            void IsFinished( const Vector2D& value);

            //! easing functions
            virtual const float None( const float time,
                                      const float offset,
                                      const float change,
                                      const float duration);
        
            virtual const float In( const float time,
                                    const float offset,
                                    const float change,
                                    const float duration);

            virtual const float Out( const float time,
                                     const float offset,
                                     const float change,
                                     const float duration);
        
            virtual const float InOut( const float time,
                                       const float offset,
                                       const float change,
                                       const float duration);
        
    }; // end of class Tween
    
} // end of namespace Meteor


#endif // ANIMATION_H